package com.lanxin.xxform.mappers;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.lanxin.xxform.beans.Paper;
import com.lanxin.xxform.tools.JetCriteria;

@Mapper
public interface PaperMapper {

    @Insert("insert into paper (title,views,submits,createTime,updateTime,note,status,uid) values (#{title},${views},${submits},${createTime},${updateTime},#{note},${status},${uid})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insert(Paper paper);

    @Select("select * from paper where id=${id}")
    Paper find(long id);

    @Select("select count(*) from paper ${condition}")
    int count(JetCriteria criteria);

    @Select("select ${select} from paper ${fullCondition}")
    List<Paper> findAll(JetCriteria criteria);

    @Update("update paper set title=#{title},updateTime=${updateTime},note=#{note},status=${status} where id=${id}")
    int update(Paper paper);

    @Delete("delete from paper where id=${id}")
    int delete(long id);
    
}
